package app.controller.goods;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import app.model.goods.GoodsStock;
import app.service.goods.GoodsStockService;
import base.JsonResult;
import base.PageInfo;

@Controller
@RequestMapping("/goodsStock")
public class GoodsStockController {
	
	private Logger logger = Logger.getLogger(GoodsStockController.class);
	
	@Autowired
	private GoodsStockService goodsStockService;
	
	@ResponseBody
	@RequestMapping("/list.do")
	public PageInfo list(PageInfo pageInfo,String goodsName){
		return goodsStockService.list(pageInfo,goodsName);
	}
	
	@ResponseBody
	@RequestMapping("/save.do")
	public JsonResult save(GoodsStock goodsStock){
		if(StringUtils.isEmpty(goodsStock.getId())){
			goodsStockService.saveEntity(goodsStock);
		}else{
			goodsStockService.updateEntity(goodsStock);
		}
		return new JsonResult("操作成功");
	}
	
	@ResponseBody
	@RequestMapping("/view.do")
	public JsonResult view(String id){
		GoodsStock goodsStock = goodsStockService.queryEntityById(id);
		return new JsonResult("操作成功",goodsStock);
	}
	
	@ResponseBody
	@RequestMapping("/del.do")
	public JsonResult del(String ids){
		goodsStockService.delEntity(ids);
		return new JsonResult("操作成功");
	}
}
